package com.example.program

import android.os.Bundle
import androidx.fragment.app.activityViewModels
import com.example.program.base.BaseFragment
import com.example.program.databinding.FragmentHomeBinding
import com.example.program.model.ClickEvent
import com.example.program.model.sharedViewModel

class HomeFragment : BaseFragment<FragmentHomeBinding>(){
    private val mViewModel : sharedViewModel by activityViewModels()


    override fun initUI(savedInstanceState: Bundle?) {
        mBinding.textView.setOnClickListener { v ->
            parentFragmentManager.beginTransaction().apply {
               // setCustomAnimations(android.R.anim.fade_in,android.R.anim.fade_out,android.R.anim.fade_in,android.R.anim.fade_out)

                setReorderingAllowed(true)
                addToBackStack(null)
                //addSharedElement()
                commit()
            }
        }

        //给dataBinding中的变量赋值
        mBinding.viewModel = mViewModel
        mBinding.clickEvent = ClickEvent()
        //给dataBinding绑定生命周期
        mBinding.lifecycleOwner = this
        //立即执行
        mBinding.executePendingBindings()

    }
}


